package Vue.Principale;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.util.Observable;
import java.util.Observer;

import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;

import LookAndFeel.Label;
import Modele.Joueur;

public class RecapRessources extends JPanel implements Observer{

	private static final long serialVersionUID = 1L;
	private Label bois = new Label("0");
	private Label pierre = new Label("0");
	private Label mercure = new Label("0");
	private Label gemme = new Label("0");
	private Label cristal = new Label("0");
	private Label soufre = new Label("0");
	private Label argent = new Label("0");
	
	
	public RecapRessources() {
		this.setLayout(new BorderLayout());
		this.setBackground(new Color(69, 53, 40));
		
		Box contenu = new Box(BoxLayout.X_AXIS);
		contenu.setBackground(Color.BLACK);
	
		JLabel labelBois = new JLabel(new ImageIcon("./src/Images/Ressources/Bois.gif")); 
		labelBois.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
		contenu.add(labelBois);
		this.bois.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
		contenu.add(Box.createHorizontalStrut(10));
		contenu.add(this.bois);
		contenu.add(Box.createHorizontalStrut(65));
		
		JLabel labelPierre = new JLabel(new ImageIcon("./src/Images/Ressources/Pierre.gif")); 
		labelPierre.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
		contenu.add(labelPierre);
		this.pierre.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
		contenu.add(Box.createHorizontalStrut(10));
		contenu.add(this.pierre);
		contenu.add(Box.createHorizontalStrut(65));
		
		JLabel labelMercure = new JLabel(new ImageIcon("./src/Images/Ressources/Mercure.gif")); 
		labelMercure.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
		contenu.add(labelMercure);
		this.mercure.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
		contenu.add(Box.createHorizontalStrut(10));
		contenu.add(this.mercure);
		contenu.add(Box.createHorizontalStrut(65));
		
		JLabel labelCristal = new JLabel(new ImageIcon("./src/Images/Ressources/Cristal.gif")); 
		labelCristal.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
		contenu.add(labelCristal);
		this.cristal.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
		contenu.add(Box.createHorizontalStrut(10));
		contenu.add(this.cristal);
		contenu.add(Box.createHorizontalStrut(65));
		
		JLabel labelGemme = new JLabel(new ImageIcon("./src/Images/Ressources/Gemme.gif")); 
		labelGemme.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
		contenu.add(labelGemme);
		this.gemme.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
		contenu.add(Box.createHorizontalStrut(10));
		contenu.add(this.gemme);
		contenu.add(Box.createHorizontalStrut(65));
		
		JLabel labelSoufre = new JLabel(new ImageIcon("./src/Images/Ressources/Soufre.gif")); 
		labelSoufre.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
		contenu.add(labelSoufre);
		this.soufre.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
		contenu.add(Box.createHorizontalStrut(10));
		contenu.add(this.soufre);
		contenu.add(Box.createHorizontalStrut(65));
		
		JLabel labelArgent = new JLabel(new ImageIcon("./src/Images/Ressources/Argent.gif")); 
		labelArgent.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
		contenu.add(labelArgent);
		this.argent.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
		contenu.add(Box.createHorizontalStrut(10));
		contenu.add(this.argent);
		contenu.add(Box.createHorizontalStrut(65));
		
		this.add(Box.createHorizontalStrut(28), BorderLayout.WEST);
		this.add(contenu, BorderLayout.CENTER);
		this.add(Box.createVerticalStrut(26), BorderLayout.SOUTH);
	}
	
	
	
	public void paintComponent(Graphics g) {
		super.paintComponent(g);
		Image image = getToolkit().getImage("./src/Images/Menu/fondRessources.png");
		g.drawImage(image, 0, 0, this);
	}

	
	

	@Override
	public void update(Observable arg0, Object arg1) {
		argent.setText(String.valueOf("<html><div color='white'>"+((Joueur)arg1).getTresorerie()+"</div></html>"));
		bois.setText(String.valueOf("<html><div color='white'>"+((Joueur)arg1).getBois()+"</div></html>"));
		pierre.setText(String.valueOf("<html><div color='white'>"+((Joueur)arg1).getPierre()+"</div></html>"));
		gemme.setText(String.valueOf("<html><div color='white'>"+((Joueur)arg1).getGemme()+"</div></html>"));
		cristal.setText(String.valueOf("<html><div color='white'>"+((Joueur)arg1).getCristal()+"</div></html>"));
		soufre.setText(String.valueOf("<html><div color='white'>"+((Joueur)arg1).getSoufre()+"</div></html>"));
		mercure.setText(String.valueOf("<html><div color='white'>"+((Joueur)arg1).getMercure()+"</div></html>"));		
	}
	
}
